package banking;

// 同包下无需import banking.*，直接访问同包类
public class TestBanking {
    public static void main(String[] args) {
        // 声明变量：客户、账户（仅声明，未初始化）
        Customer customer;
        Account account;

        // 1. 创建客户（Jane Smith）
        System.out.println("Creating the customer Jane Smith.");
        customer = new Customer("Jane", "Smith");

        // 2. 为客户创建账户（初始余额500.00）并关联
        System.out.println("Creating her account with a 500.00 balance.");
        customer.setAccount(new Account(500.00));
        // 从客户对象中获取关联的账户（后续操作账户用此引用）
        account = customer.getAccount();

        // 3. 执行账户交易并打印结果（true=成功，false=失败）
        System.out.println("Withdraw 150.00: " + account.withdraw(150.00)); // 余额500→350，成功
        System.out.println("Deposit 22.50: " + account.deposit(22.50));   // 余额350→372.5，成功
        System.out.println("Withdraw 400.00: " + account.withdraw(400.00)); // 余额372.5<400，失败
        System.out.println("Withdraw 47.62: " + account.withdraw(47.62));   // 余额372.5→324.88，成功

        // 4. 打印客户最终账户余额
        System.out.println("Customer [" + customer.getLastName() + ", " + customer.getFirstName()
                + "] has a balance of " + account.getBalance());
    }
}